<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ page import="mybatis.pojo.Page" %>
<%@ page import="mybatis.pojo.Student" %>
<%@ page import="mybatis.services.GradeService" %>
<%@ page import="mybatis.services.StudentService" %>
<%@ page import="mybatis.util.StrUtil" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<script src="js/jquery.js"></script>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>超市账单管理系统</title>
    <link rel="stylesheet" href="css/public.css"/>
    <link rel="stylesheet" href="css/style.css"/>
</head>
<body>
<%@include file="checkLogin.jsp" %>
<!--主体内容-->

<section class="publicMian ">

    <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>学生管理</span>
            <%
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                request.setCharacterEncoding("utf-8");
                String stuName = request.getParameter("stuName");
                stuName = stuName == null ? "" : stuName;
                int pageNo = StrUtil.toInt(request.getParameter("pageNo"), 1);
                String wechat=StrUtil.toStr(request.getParameter("wechat"));
                String qq=StrUtil.toStr(request.getParameter("qq"));
                Date start=StrUtil.toDate(request.getParameter("start"));
                Date end=StrUtil.toDate(request.getParameter("end"));

            %>
        </div>
        <div class="search">
            <form action="student.jsp" method="post" id="seachForm">
                <input type="hidden" name="pageNo" id="pageNo" value="<%=pageNo%>">
                <span>学生名称：</span>
                <label for="stuName">学生姓名</label>
                <input id="stuName" type="search" name="stuName" value="<%=StrUtil.toStr(stuName)%>">
                <label for="wechat">微信</label>
                <input id="wechat" type="search" name="wechat" value="<%=wechat%>">
                <label for="qq">QQ</label>
                <input id="qq" type="search" name="qq" value="<%=qq%>"><br/>
                <label for="start">入学日期</label>
                <input id="start" type="date" name="start" value="<%=StrUtil.toStr(start)%>">
                <label for="end">-</label>
                <input id="end" type="date" name="end" value="<%=StrUtil.toStr(end)%>">
                <input type="submit" value="查询" style="width: 100px;height: 36px"/>
            </form>
            <a href="studentAdd.jsp">添加</a>
        </div>

        <!--供应商操作表格-->
        <table class="providerTable" cellpadding="0" cellspacing="0">
            <tr class="firstTr">
                <th width="10%">编号</th>
                <th width="10%">姓名</th>
                <th width="10%">性别</th>
                <th width="10%">电话</th>
                <th width="10%">qq</th>
                <th width="10%">微信</th>
                <th width="10%">年级</th>
                <th width="10%">入学时间</th>
                <th width="10%">来自城市</th>
                <th width="10%">出生日期</th>
                <th width="10%">家庭住址</th>
                <th width="10%">密码</th>
                <th width="10%">身份证号</th>
            </tr>
            <%
                Page<Student> student = StudentService.ME.showStuLike(pageNo,wechat,qq,stuName,start,end);

                for (Student stu : student.getDatas()) {

            %>
            <tr>
                <td><%=stu.getStuno()%>
                </td>
                <td><%=stu.getSname()%>
                </td>
                <td><%=stu.getSex()%>
                </td>
                <td><%=stu.getTelephone()%>
                </td>
                <td><%=stu.getQq()%>
                </td>
                <td><%=stu.getWechat()%>
                </td>
                <td><%= GradeService.ME.find(stu.getGradeid()).getGname()%>
                </td>
                <td><%=stu.getEnterdate() == null ? "无日期信息" : StrUtil.toDate(stu.getEnterdate().toString())%>
                </td>
                <td><%=stu.getFromcity()%>
                </td>
                <td><%=stu.getBirthday() == null ? "无日期信息" : StrUtil.toDate(stu.getBirthday().toString())%>
                </td>
                <td><%=stu.getAddress()%>
                </td>
                <td><%=stu.getPass()%>
                </td>
                <td><img src="<%=stu.getIdcardpic()%>">
                </td>

                <td>

                    <a href="providerView.html"><img src="img/read.png" alt="查看" title="查看"/></a>
                    <a href="studentUpdate.jsp?stuno=<%=stu.getStuno()%>"><img src="img/xiugai.png" alt="修改"
                                                                               title="修改"/></a>
                    <a href="stuDelete.jsp?id=<%=stu.getStuno()%> " class="removeProvider"
                       onclick="return confirm('确认是否删除')"><img src="img/schu.png" alt="删除" title="删除"/></a>
                </td>
            </tr>
            <%}%>
        </table>
        <p align="center" class="pager">
            <a href="#" id="prev">首页</a>
            <%
                if (pageNo > 1) {
            %>
            <a id="prev" href="#" data-page="<%=pageNo-1%>">上一页</a>
            <%}%>
            <input type="number" name="pa" value="<%=pageNo%>" style="..." size="4" min="1"
                   max="<%=student.getTotalPages()%>">/<%=student.getTotalPages()%>
            <button type="button" id="gotoPage">Go</button>
            <% if (pageNo < student.getTotalPages()) {%>
            <a href="#" id="next" data-page="<%=pageNo+1%>">下一页</a>
            <%}%>
            <a href="#" id="next" data-page="<%=student.getTotalPages()%>">尾页</a>
        </p>
    </div>
</section>
<!--点击删除按钮后弹出的页面-->
<div class="zhezhao"></div>
<div class="remove" id="removeProv">
    <div class="removerChid">
        <h2>提示</h2>
        <div class="removeMain">
            <p>你确定要删除该供应商吗？</p>
            <a href="#" id="yes">确定</a>
            <a href="#" id="no">取消</a>
        </div>
    </div>
</div>
<%--<tr class="alt">--%>
<%--<td class="center" colspan="3">--%>
<%--共<%=totalRecord%>条记录&nbsp;--%>

<%--</td>--%>
<%--</tr>--%>
<script src="js/jquery.js">
</script>

<script>

    <%--$(function () {--%>
    <%--$("form#seachForm :submit").click(function () {--%>
    <%--$("#pageNo").val(1);//每次搜索，页号从1开始--%>
    <%--return true;--%>
    <%--});--%>
    <%--$(".pager #goPage").click()(function () {--%>
    <%--let pageNo=$(this).prev().val();--%>
    <%--if (pageNo<1||pageNo><%=student.getTotalPages()%>){--%>
    <%--alert("页数输入有误，请重新输入");--%>
    <%--return false;--%>
    <%--}--%>
    <%--$("form#seachForm #pageNo").val(pageNo);--%>
    <%--$("form#seachForm").submit();//手工提交表单--%>
    <%--return false;//让a 链接失效--%>
    <%--});--%>
    <%----%>
    <%--$(".pager a").click(function () {--%>
    <%--let pageNo = $(this).data("page");--%>
    <%--$("#pageNo").val(pageNo);--%>
    <%--$("form#seachForm").submit();//手工提交表单--%>
    <%--return false;//让a 链接失效--%>

    <%--});--%>
    <%--});--%>
    $(function () {
        $("form#seachForm :submit").click(function () {
            $("#pageNo").val(1);//每次搜索，页号从1开始
            return true;
        });
        $(".pager #gotoPage").click(function () {
            let pageNo = $(this).prev().val();
            if (pageNo < 1 || pageNo ><%=student.getTotalPages()%>) {
                alert("页数有误");
                return false;
            }
            $("form#seachForm #pageNo").val(pageNo);
            $("form#seachForm").submit();//手工提交表单
            return false;
        });
        $(".pager a").click(function () {
            let pageNo = $(this).data("page");
            $("#pageNo").val(pageNo);
            $("form#seachForm").submit();//手工提交表单
            return false;//让a 链接失效
        });
    });
</script>

</body>
</html>
